package com.gxa.jjty.phy.controller;

import com.github.pagehelper.PageInfo;
import com.gxa.jjty.core.common.JsonResult;
import com.gxa.jjty.core.pojo.*;
import com.gxa.jjty.phy.service.HandicappedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

@Log4j2
@Api(tags = "残疾人管理接口")
@RestController
@RequestMapping("/handicapped")
@Transactional(rollbackFor = Throwable.class)
@Validated
public class HandicappedController {

    @Autowired
    HandicappedService handicappedService;


    @PostMapping("/selectAll")
    @ApiOperation("全查询")
    public Map<String,Object> selectAll(){
        List<Handicapped> list = handicappedService.selectAll();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(list);
        return jsonResult.getDataMap();
    }

    @PostMapping("/selectById")
    @ApiOperation("根据id查询地址")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "残疾人id")
    })
    public Map<String,Object> selectById(Long id){
        Handicapped handicapped = handicappedService.selectById(id);
        String address = handicapped.getAddress();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(address);
        return jsonResult.getDataMap();
    }


}
